package ministock;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import weibo4j.Comment;
import weibo4j.RateLimitStatus;
import weibo4j.Weibo;
import weibo4j.WeiboException;

public class MyWeibo extends Weibo {

	private static final Logger logger = LoggerFactory.getLogger(MyWeibo.class);
	
	private static final long serialVersionUID = -102933317140403837L;
	
	private static final MyWeibo singleton = new MyWeibo();
	
	private MyWeibo() {
		super(MiniStock.getUserKey(), MiniStock.getUserSecret());
	}
	
	public static MyWeibo getInstance() {
		return singleton;
	}
	
	@Override
	public Comment updateComment(String comment, String id, String cid)
			throws WeiboException {
		RateLimitStatus rate = getRateLimitStatus();
		if(rate.getRemainingHits() > 0) {
			logger.debug("remaining rate hits:{}", rate.getRemainingHits());
			return super.updateComment(comment, id, cid);
		}
		return null;
	}
}
